<?php
namespace app\admin\model;
use app\common\BaseModel;


class Role extends BaseModel{
	protected $paginate = 2;
	public function add_save_Role(){
		if(!input('id'))
			return $this->save(object_to_array(input()));
		else{
			$row = $this->where('id',input('id'))->update(object_to_array(input()));
			if($row !==1){
				return true;
			}
			return true;
		}
		
	}
	
	public function Aselect($page,$limit){

		$role = $this->limit(($page-1)*$limit,$limit)->select();
		$total = $this->count();
		return ['code'=>0,'role'=>$role,'total'=>$total,'paginate'=>$this->paginate];
	}

	public static function getAllRole(){
		$role = new self;
		return $role->all();
	}
}